project(ksvgeditor_ui)

SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
#SET(CMAKE_AUTORCC ON)
SET(CMAKE_AUTOUIC ON)

find_package(Qt5 REQUIRED COMPONENTS Widgets Core Gui)

set(UI_FILES
    kmainwindow.ui
    ktoolpanelwidget.ui
    kdrawsettingpanelwidget.ui
)

# Widgets
set(WIDGET_HEADER_FILES
    kmainwindow.h
    kdrawinggraphicsview.h
    ktoolpanelwidget.h
    kdrawsettingpanelwidget.h
    kglobalviewconstants.h
)
set(WIDGET_CPP_FILES
    kmainwindow.cpp
    kdrawinggraphicsview.cpp
    ktoolpanelwidget.cpp
    kdrawsettingpanelwidget.cpp
)

# Custom Buttons
set(BUTTON_HEADER_FILES
    ktoolbutton.h
)
set(BUTTON_CPP_FILES
    ktoolbutton.cpp
)

# Interaction Strategies
set(INTERACTION_HEADER_FILES
    kinteractionmodestrategy.h
    kdrawmodestrategy.h
    kselectmodestrategy.h
    kzoommodestrategy.h
    kmodestrategyfactory.h
)
set(INTERACTION_CPP_FILES
    kinteractionmodestrategy.cpp
    kdrawmodestrategy.cpp
    kselectmodestrategy.cpp
    kzoommodestrategy.cpp
    kmodestrategyfactory.cpp
)

# Context Menu Strategies
set(MENU_HEADER_FILES
    kbasicmenustrategy.h
    kemptymenustrategy.h
    ksinglemenustrategy.h
    kmutiplemenustrategy.h
    kmenustrategyfactory.h
    kmenuinfo.h
)
set(MENU_CPP_FILES
    kbasicmenustrategy.cpp
    kemptymenustrategy.cpp
    ksinglemenustrategy.cpp
    kmutiplemenustrategy.cpp
    kmenustrategyfactory.cpp
)

# Shape Setting
set(SHAPESETTING_HEADER_FILES
    kshapesettingstrategy.h
    kshapesettingfactory.h
)
set(SHAPESETTING_CPP_FILES
    kshapesettingfactory.cpp
)

# 汇总
set(HEADER_FILES)
set(CPP_FILES)

list(APPEND HEADER_FILES
    ${WIDGET_HEADER_FILES}
    ${INTERACTION_HEADER_FILES}
    ${MENU_HEADER_FILES}
    ${BUTTON_HEADER_FILES}
    ${SHAPESETTING_HEADER_FILES}
)

list(APPEND CPP_FILES
    ${WIDGET_CPP_FILES}
    ${INTERACTION_CPP_FILES}
    ${MENU_CPP_FILES}
    ${BUTTON_CPP_FILES}
    ${SHAPESETTING_CPP_FILES}
)

set(RCC_FILES)

# 分组显示
source_group("Form Files" FILES ${UI_FILES})
source_group("Widget Files" FILES ${WIDGET_HEADER_FILES} ${WIDGET_CPP_FILES})
source_group("Interaction Strategies" FILES ${INTERACTION_HEADER_FILES} ${INTERACTION_CPP_FILES})
source_group("Context Menu Strategies" FILES ${MENU_HEADER_FILES} ${MENU_CPP_FILES})
source_group("Resource Files" FILES ${RCC_FILES})
source_group("Custom Buttons" FILES ${BUTTON_HEADER_FILES} ${BUTTON_CPP_FILES})
source_group("Shape Setting" FILES ${SHAPESETTING_HEADER_FILES} ${SHAPESETTING_CPP_FILES})

# 编译目标
add_library(${PROJECT_NAME} STATIC ${HEADER_FILES} ${CPP_FILES} ${UI_FILES} ${RCC_FILES})

# 头文件路径
target_include_directories(${PROJECT_NAME} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

# 链接依赖
target_link_libraries(${PROJECT_NAME} PUBLIC
    ksvgeditor_core
    ksvgeditor_config
    Qt5::Widgets
    Qt5::Core
    Qt5::Gui
)

set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Libraries/UI")